import request from "@/utils/request.js";

/**
 * 用户登录
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const userLoginService = (data) =>{
    return request.post('/user/login', data);
}

/**
 * 用户注册
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const userRegisterService = (data) =>{
    return request.post('/user/register', data);
}

/**
 * 获取用户信息
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const getUserInfoService = () =>{
    return request.get('/user/info');
}

/**
 * 修改用户信息
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const updateUserInfoService = (data) =>{
    return request.put('/user/info', data);
}

/**
 * 用户修改密码
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const changePasswordService = (data) =>{
    return request.put('/user/changePwd', data);
}

/**
 * 用户头像修改
 * @param avatarUrl
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const userAvatarUpdateService = (avatarUrl) =>{
    const params = new URLSearchParams();
    params.append('avatarUrl', avatarUrl)
    return request.patch('/user/updateAvatar', params);
}